<?php
/**
 * 啊
 */
class ActiveModel extends CommonModel {
	
	protected $tableName = 'hwl_active';

           
	public function saveRow ($data,$id = false) {

        if($id !== false) {

            $res = pdo_update($this->tableName,$data,['id' => $id]);  //更新操作，用微擎函数，参数为表名，数据，ID

        } else {
          	$res = pdo_insert($this->tableName,$data);

        }
        return $res;

	}


    public function getList($page = 1){
             
        $this->query->from($this->tableName,'act')
                   ->select('act.*','cate.title AS active_cate_title','suser.name AS service_user_name' )
                   ->leftjoin('hwl_active_cate','cate')
                   ->on('act.active_cate_id','cate.id')
                   ->leftjoin('hwl_service_user','suser')
                   ->on('act.service_user_id','suser.id')
                   ->orderby('act.create_time','DESC')
                   ->orderby('act.id','DESC');
             


        if($page === false) {

            return $this->getall();
        }

        $page = (int)$page;
        if($page <= 0) {

            $page = 1;
        }

       
        $pageIndex = $page;
        $pageSize  = 10;
        $list      = $this->page($pageIndex, $pageSize)->getall();
        $total     = $this->getLastQueryTotal();

        $this->pageHtml = pagination($total, $pageIndex, $pageSize);
       // $list = $this->query->from($this->tableName)->getall();
        return $list;

    }





}



?>